The script uses a cookie, ETUQuoteCount
, to remember between visits where it's
been in the list. Unlike using random numbers, the user will see all the quotes before they
start to repeat.
This script uses the construction method to dynamically create an
array of objects and the array.length
property so the script user doesn't have to worry about the number of elements or finding
all the locations of specific constants.
<SCRIPT LANGUAGE="JavaScript"><!-- // ******************************************************** // To Use this Script, simply change the quotes below // That's all there is; no code to change. // NOTE: use a \ before any ' or " characters that inside // your quotes // ******************************************************** var quoteList = new Array( // ************************************** // Place Quotes Here, Separated by Commas // ************************************** "Back Up My Hard Drive? How do I Put it in Reverse?", "What we have here is a failure to assimilate.<BR>[Cool Hand Locutus]", "I just got lost in thought. It was unfamiliar territory.", "Nearly all men can stand adversity, but if you want to test a man's character, give him power.<BR>[Abraham Lincoln]", "When you are out of whack, the best thing to do is to order more whack.<BR>[D. Jacquet]", "When you said you wanted to live in sin, I didn\'t know you meant \"sloth\".<BR>[David Oster]", "Those who live by the sword get shot by those who don\'t.", "People who censor books are usually illiterate.<BR>[John D. MacDonald, A Purple Place for Dying, 1964]", "I feel like I\'m diagonally parked in a parallel universe.", "He's not dead, He\'s electroencephalographically challenged.", "A day without sunshine is like, you know, night.", "Atheism is a non-prophet organization.", "The worst thing you write is better than the best thing you didn\'t write.<BR>[Unknown]", "Photons have mass? I didn\'t know they were catholic!", "A polar bear is a rectangular bear after a coordinate transform." // ********************************* // !NOTE: No Comma after last Quote! // ********************************* ); // ************ // Get a Cookie // ************ function getCookie(name) { var search = name + "=" if (document.cookie.length > 0) { // if there are any cookies offset = document.cookie.indexOf(search) if (offset != -1) { // if cookie exists offset += search.length // set index of beginning of value end = document.cookie.indexOf(";", offset) // set index of end of cookie value if (end == -1) end = document.cookie.length return unescape(document.cookie.substring(offset, end)) } } } // ************ // Set a Cookie // ************ function setCookie(name, value) { document.cookie = name + "=" + escape(value) } // *************************************** // Function to get the next quote in order // *************************************** function quote() { i=getCookie("ETUQuoteCount"); if (i==null) i=0 else i=parseInt(i) i = i % quoteList.length; j = i++; setCookie("ETUQuoteCount",i); return quoteList[j] } // ******************* // Write the Quote Out // ******************* document.write(quote()); // --></SCRIPT>